//
//  YCFoodServiceViewController.m
//  YCSchool
//
//  Created by gmall on 16/5/6.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//  餐饮服务

#import "YCFoodServiceViewController.h"

@interface YCFoodServiceViewController ()<SDCycleScrollViewDelegate>

/** 文本标签  */
@property (nonatomic, weak) UILabel *textLabel;
/** 文本内容  */
@property (nonatomic, copy) NSString *text;

/** scrollview  */
@property (nonatomic, weak) UIScrollView *scrollView;

@end


@implementation YCFoodServiceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self yc_addBackBarButtonItem];
    self.navigationItem.title = @"餐饮服务";
    [self makeView];
    self.text = @"我校设多个学员餐厅，由专业的营养师提供色、香、味俱全的中式美餐。\n\n食堂地址:\n1.综合楼一楼一号食堂\n2.考试中心食堂\n3.一乘驾校清真园";
}

- (void)makeView
{

    UIScrollView *scrollView = [[UIScrollView alloc] init];
    [self.view addSubview:scrollView];
    scrollView.showsHorizontalScrollIndicator = NO;
    scrollView.showsVerticalScrollIndicator = NO;
    self.scrollView = scrollView;
    
    // uiscrollView布局,要一个中间容器view
    UIView *containView = [[UIView alloc] init];
    [self.scrollView addSubview:containView];
    
    [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    
    [containView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(scrollView);
        make.width.equalTo(scrollView);
    }];
    
    SDCycleScrollView *sdcycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, kScreenWidth, 202) delegate:self placeholderImage:[UIImage yc_placeHolderImageForSize:CGSizeMake(kScreenWidth, 202)]];
    sdcycleScrollView.imageURLStringsGroup = @[@"http://img1.3lian.com/2015/w7/98/d/22.jpg",
                                               @"http://img1.3lian.com/2015/w7/90/d/5.jpg",
                                               @"http://img1.3lian.com/2015/w7/90/d/1.jpg",
                                               @"http://pic37.nipic.com/20140209/8821914_163234218136_2.jpg",
                                               @"http://pic39.nipic.com/20140226/18071023_162553457000_2.jpg",
                                               @"http://imgsrc.baidu.com/forum/pic/item/645b8701a18b87d6e716e197070828381e30fdae.jpg"];//网络图片链接数组
    sdcycleScrollView.delegate = self;
    sdcycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
    sdcycleScrollView.pageDotColor = [UIColor yc_colorWithUInt:0xffffff alpha:0.5];
    sdcycleScrollView.currentPageDotColor = [UIColor yc_colorWithUInt:0xffffff];
    sdcycleScrollView.pageControlDotSize = CGSizeMake(12, 12);
    sdcycleScrollView.hidesForSinglePage = YES;
    sdcycleScrollView.autoScrollTimeInterval = 2.0;//2s自动轮播
    
    [containView addSubview:sdcycleScrollView];
    [sdcycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(containView).offset(15);
        make.right.equalTo(containView).offset(-15);
        make.height.equalTo(sdcycleScrollView.mas_width);
    }];
    // 添加广本介绍
    UILabel *textLabel = [[UILabel alloc] init];
    textLabel.numberOfLines = 0;
    textLabel.font = [UIFont systemFontOfSize:15];
    textLabel.textColor = [UIColor yc_colorWithUInt:0x666666];
    [containView addSubview:textLabel];
    self.textLabel = textLabel;
    
    [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(sdcycleScrollView.mas_bottom).offset(15);
        make.left.equalTo(containView).offset(15);
        make.right.equalTo(containView).offset(-15);
    }];
    
    [containView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(textLabel.mas_bottom).offset(0);
    }];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

// 设置文字内容
- (void)setText:(NSString *)text
{
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
    style.firstLineHeadIndent = 26;//首行缩进
    style.lineSpacing = 7;//行距
    style.alignment=NSTextAlignmentLeft;
    
    NSAttributedString *textValue = [[NSAttributedString alloc]initWithString:text attributes:@{NSParagraphStyleAttributeName:style}];
    
    self.textLabel.attributedText= textValue;
    
}

@end
